package com.chi.thread.thread;

/**
 * 创建线程的第一种方式，用sychronize保证int类型线程安全
 * @author chi  2017-06-22 21:32
 **/
public class MyThread extends Thread{

    private static int a = 1;

    @Override
    public void run() {
        synchronized (MyThread.class) {
            System.out.println(a++);
        }
    }

    public static void main(String[] args){
        for (int i = 1; i<100 ; i++){
            new MyThread().start();
        }
    }
}
